const mysql = require("mysql")
const { dbconfig } = require("../config/config")

const con = mysql.createConnection(dbconfig)

con.connect()

function exec(sql) {
  const promise = new Promise((resolve, reject) => {
    con.query(sql, (err, result) => {
      if (err) {
        reject(err)
      }
      if (result) {
        resolve(result)
      }
    })
  })
  return promise
}

module.exports = {
  exec
}
